package BuyerAgent;

import jade.core.behaviours.OneShotBehaviour;

/**
 * This class is the behavior of the agent in which agent will come back its
 * home container after the stop conditions are met. Stop conditions are either
 * wish list is empty, or the number of attempts equal to the maximum number of
 * attempts
 * 
 * @author DUY HAN PHAN
 * 
 */
public class ComeBackHomeContainerBehaviour extends OneShotBehaviour {
	private volatile Buyer buyerAgent;

	/**
	 * @param buyerAgent
	 */
	public ComeBackHomeContainerBehaviour(Buyer buyerAgent) {
		this.buyerAgent = buyerAgent;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see jade.core.behaviours.Behaviour#action()
	 */
	@Override
	public void action() {
		// check if current location is main container
		if (!buyerAgent.here().equals(buyerAgent.mainContainerLocation)) {
			System.out.println("ERROR!!! the agent is not at main container");
			return;
		}
		System.out.println("Agent is comming back home " + buyerAgent.homeLocationOfBuyerAgent);
		buyerAgent.doMove(buyerAgent.homeLocationOfBuyerAgent);
	}

}
